package com.paas.form.core.element.constants;

public class TableConstant {

    public static final String VM_TABLE_HEAD_HTMl = "<el-table :data=\"pageBean.data\" stripe border header-row-class-name=\"tab-header\">";
    public static final String VM_TABLE_END_HTMl =  "                    </el-table>\n";

    public static final String VM_TABLE_COLUMN_SELECTION ="                        <el-table-column type=\"selection\" width=\"55\"></el-table-column>";
    public static final String VM_TABLE_COLUMN_INDEX ="                        <el-table-column type=\"index\" label=\"序号\" width=\"50\"></el-table-column>";
    public static final String VM_TABLE_COLUMN_NONE ="                        <el-table-column prop=\"${field.vModel}\" label=\"${field.config.label}\"></el-table-column>";
    public static final String VM_TABLE_COLUMN_INPUT ="";
    public static final String VM_TABLE_COLUMN_BUTTON ="                            <el-button type=\"primary\" plain @click=\"${button.value}(scope.row.id)\">${button.label}</el-button>";

    public static final String VM_TABLE_COLUMN_BUTTON_START = "\n                        <el-table-column fixed=\"right\" label=\"操作\"  width=\"300\">\n" +
            "                            <template slot-scope=\"scope\">";

    public static final String VM_TABLE_COLUMN_BUTTON_END = "\n                           </template>\n" +
            "                        </el-table-column>\n";
    //分页部分
    public static final String VM_TABLE_PAGINATION = "                    <el-pagination\n" +
            "                        class=\"text-center mt10\"\n" +
            "                        @size-change=\"sizeChangeHandle\"\n" +
            "                        @current-change=\"currentChangeHandle\"\n" +
            "                        :current-page=\"pageBean.currentPage\"\n" +
            "                        :page-sizes=\"[5, 10, 20, 50, 100]\"\n" +
            "                        :page-size=\"pageBean.pageSize\"\n" +
            "                        :total=\"pageBean.totalPage\"\n" +
            "                        layout=\"total, sizes, prev, pager, next, jumper\"\n" +
            "                        >\n" +
            "                    </el-pagination>";

    //js部分Data
    public static final String VM_TABLE_JS_DATA = "                pageBean: {\n" +
            "                    currentPage: 1,\n" +
            "                    pageSize: 10,\n" +
            "                    data: [],\n" +
            "                    totalPage: 0,\n" +
            "                },";


    //js部分import

    public static final String VM_TABLE_JS_IMPORT = "import ${className}Service from \"@/service/form/${classNameUtU}Service\";" +
            "\nimport GenFormInput from \"./form\";";

    //js部分methods
    public static final String VM_TABLE_JS_METHODS_GETDATALIST = "/**\n" +
            "     * 列表查询\n" +
            "     */\n" +
            "    async getDataList(currentPage) {\n" +
            "      // 新增、搜索，返回到第一页\n" +
            "      if (currentPage) {\n" +
            "        this.pageBean.currentPage = currentPage;\n" +
            "      }\n" +
            "      try {\n" +
            "        let params = {\n" +
            "          currentPage: this.pageBean.currentPage,\n" +
            "          pageSize: this.pageBean.pageSize,\n" +
            "          ...this.searchForm,\n" +
            "        };\n" +
            "        const resp = await ${className}Service.queryPage(params);\n" +
            "        if (resp.status !== 200) {\n" +
            "          throw new Error(\"接口请求失败, status: \" + resp.status);\n" +
            "        }\n" +
            "        this.pageBean.totalPage = resp.data.total;\n" +
            "        this.pageBean.data = resp.data.records;\n" +
            "      } catch (e) {\n" +
            "        this.$message({\n" +
            "          showClose: true,\n" +
            "          message: \"加载列表失败，错误：\" + e.message,\n" +
            "          type: \"error\",\n" +
            "        });\n" +
            "      }\n" +
            "    },\n" +
            "\n" +
            "    /**\n" +
            "     * 当前页\n" +
            "     */\n" +
            "    currentChangeHandle(val) {\n" +
            "      this.pageBean.currentPage = val;\n" +
            "      this.searchForm = {};\n" +
            "      this.getDataList();\n" +
            "    },\n" +
            "\n" +
            "    /**\n" +
            "     * 每页数\n" +
            "     */\n" +
            "    sizeChangeHandle(val) {\n" +
            "      this.pageBean.pageSize = val;\n" +
            "      this.pageBean.currentPage = 1;\n" +
            "      this.getDataList();\n" +
            "    },\n" +
            "\n" +
            "    /**\n" +
            "     * 查询条件重置刷新\n" +
            "     */\n" +
            "    clearSearchAll() {\n" +
            "      this.pageBean = {\n" +
            "        currentPage: 1,\n" +
            "        pageSize: 10,\n" +
            "        data: [],\n" +
            "        totalPage: 0,\n" +
            "      };\n" +
            "      this.searchForm = {};\n" +
            "      this.getDataList();\n" +
            "    },";

    //js部分add/del默认方法
    public static final String VM_TABLE_JS_METHODS_BUTTON_FUNC = "     /**\n" +
            "     * 新增\n" +
            "     */\n" +
            "    add() {\n" +
            "      this.$refs.genFormInput.init(this.resId);\n" +
            "    },\n" +
            "\n" +
            "    /**\n" +
            "     * 修改\n" +
            "     */\n" +
            "    edit(id) {\n" +
            "      this.$refs.genFormInput.init(this.resId, id);\n" +
            "    },\n" +
            "\n" +
            "    /**\n" +
            "     * 删除\n" +
            "     */\n" +
            "    remove(id) {\n" +
            "      this.$confirm(\"确认是否删除?\", \"提示\", {\n" +
            "        confirmButtonText: \"确定\",\n" +
            "        cancelButtonText: \"取消\",\n" +
            "        type: \"warning\",\n" +
            "      })\n" +
            "        .then(() => {\n" +
            "          ${[className]}Service.delectById({ id: id }).then(() => {\n" +
            "            this.$message({\n" +
            "              type: \"success\",\n" +
            "              message: \"删除成功!\",\n" +
            "            });\n" +
            "            this.getDataList();\n" +
            "          });\n" +
            "        })\n" +
            "        .catch(() => {});\n" +
            "    }," +"" +
            "    /**\n" +
            "     * 详情\n" +
            "     */\n" +
            "    detail(id){\n" +
            "        this.$refs.genFormInput.init(this.resId, id,true);\n" +
            "    },";



    public static final String vuePage = "<template>\n" +
            "    <div class=\"com_main ptb30 plr20\">\n" +
            "        <div class=\"h100 display-flex\">\n" +
            "            <!-- 左边树结构-->\n" +
            "            ${treeVue}\n" +
            "            <div class=\"tree-right\" ${rightStyle}>\n" +
            "                <div class=\"h100\">\n" +
            "                    <!-- 头部标题或按钮 -->\n" +
            "                    ${searchVue}\n" +
            "                    <!-- 表格 -->\n" +
            "                    ${tableVue}\n" +
            "                </div>\n" +
            "            </div>\n" +
            "        </div>\n" +
            "       <GenFormInput ref=\"genFormInput\" @refreshDataList=\"getDataList\"></GenFormInput>" +
            "    </div>\n" +
            "</template>\n" +
            "\n" +
            "\n" +
            "<script>\n" +
            "${jsImport}\n" +
            "    export default {\n" +
            "        name: \"tempTest\",\n" +
            "        components: { ${jsComponents} }," +
            "\n" +
            "        data() {\n" +
            "            return {\n" +
            "                isSearch: false," +
            "                ${jsData}\n" +
            "            };\n" +
            "        },\n" +
            "        async created() {\n" +
            "            await this.getDataList();\n" +
            "        }," +
            "\n" +
            "        methods: {\n" +
            "            ${jsMethods}\n" +
            "        },\n" +
            "\n" +
            "    }\n" +
            "</script>\n" +
            "\n" +
            "<style scoped>\n" +
            "    .com_main .el-form-item--small.el-form-item{\n" +
            "        margin-bottom: 18px;\n" +
            "    }\n" +
            "</style>";



}
